﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TYLitedbBase;

namespace DSPara
{
    public class SortParaCreator :CreatorBase
    {
       
        internal static LiteDB_BaseHelper<Entity_SortPara> dbHelper;

        public SortParaCreator(string dbName):base(dbName)
        { 
            dbHelper = new LiteDB_BaseHelper<Entity_SortPara>(dbName);
        }

        public bool Init(SortPara _sortPara, ref string error)
        {
            string sectionId = _sortPara.Section;
            if (!dbHelper.Get(x => x.IsDefault == true && x.SectionId == sectionId, out Entity_SortPara entity_sort))
            {
                error = $"{_sortPara.Section}获取分选配置异常!";
                return false;
            }
            if (entity_sort == null)
            {
                error = $"{_sortPara.Section}:请先配置分选配置!再重新启动软件";
                return false;
            }
            _sortPara.Init(entity_sort);
            return true;
        }
    }
}